package com.ndky.annotation.annotation.inherited;

import java.lang.annotation.Annotation;

/**
 * @Inherited 注解测试 在 Father 类中修改注解
 * 结果说明:
 *      @Inherited 父类的注解被子类继承
 * author: 核桃
 * date: 2023/11/16
 **/
public class AnnoTest {
    public static void main(String[] args) {

        // 打印父类注解信息
        Annotation[] fatherAnnotations = Father.class.getAnnotations();
        System.out.println("------- 父类 Father 信息 --------");
        System.out.println("父类注解个数：" + fatherAnnotations.length);
        for (Annotation fa : fatherAnnotations) {
            System.out.println(fa.annotationType().getSimpleName());
        }
        // 打印子类注解信息
        Annotation[] childAnnotations = Child.class.getAnnotations();
        System.out.println("------- 子类 Child 信息 --------");
        System.out.println("子类注解个数：" + childAnnotations.length);
        for (Annotation ca: childAnnotations) {
            System.out.println(ca.annotationType().getSimpleName());
        }

    }
}

